<%@page import="java.sql.Date"%>
<%@page import="model.User"%>
<%@page import="dao.BaomatDAO"%>
<%@page import="model.Baomat"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>


<jsp:include page="includes/header.jsp"></jsp:include>
<div id="maincontent">


	<!--content_infomation-->
	<div id="content_infomation">
		<jsp:include page="includes/personleft.jsp"></jsp:include>

		<%
			request.setCharacterEncoding("utf-8");
			response.setCharacterEncoding("utf-8");
			String isLogin = "";
			String emailbaove = "", cmnd = "", ngaycap = "", noicap = "";
			String err_changeprotect = "", finish_changeprotect;
			User user = new User();
			if (session.getAttribute("user") != null) {
				user = (User) session.getAttribute("user");
			}
			ArrayList<Baomat> listBaomat = BaomatDAO.select(user.getEmail());

			if (request.getAttribute("emailbaove") != null) {
				emailbaove = (String) request.getAttribute("emailbaove");
			}
			if (request.getAttribute("cmnd") != null) {
				cmnd = (String) request.getAttribute("cmnd");
			}
			if (request.getAttribute("ngaycap") != null) {
				ngaycap = (String) request.getAttribute("ngaycap");
			}
			if (request.getAttribute("noicap") != null) {
				noicap = (String) request.getAttribute("noicap");
			}
			// Lỗi thông tin
			if (request.getAttribute("err_changeprotect") == null) {
				err_changeprotect = "";
			} else {
				err_changeprotect = (String) request
						.getAttribute("err_changeprotect");
			}

			if (request.getAttribute("finish_changeprotect") == null) {
				finish_changeprotect = "";
			} else {
				finish_changeprotect = (String) request
						.getAttribute("finish_changeprotect");
			}
		%>
		<!-- Điều kiện vào trang -->
		<%
			if (session.getAttribute("isLogin") != null) {
				isLogin = (String) session.getAttribute("isLogin");
			}
			if (isLogin.equalsIgnoreCase("0")) {
				request.setAttribute("err", "Bạn vui lòng đăng nhập trước!");
				RequestDispatcher rd = getServletContext()
						.getRequestDispatcher("/dangnhap.jsp");
				rd.forward(request, response);
			} else {
		%>

		<!--Right-->
		<form action="Xulythemthongtinbaomat" method="post">
			<div id="infomation_right">
				<div class="title">THÔNG TIN BẢO MẬT</div>
				<div id="infouser">
					<div class="inforow">
						<label class="index">Email bảo vệ:</label>
						<div id="click-an-hien" style="cursor: pointer;">
							<span id="an-hiden" style="color: #008080;">Cập nhật</span>
						</div>
						<div class="infotext">
							<%
								String sEmailbaove = "";
									for (Baomat baomat : listBaomat) {
										if (baomat.getEmailbaove() != null) {
											sEmailbaove = baomat.getEmailbaove();
										} else {
											sEmailbaove = "(chưa có thông tin)";
										}
							%>
							<label class="text"><%=sEmailbaove%></label>
							<%
								}
							%>
						</div>

					</div>


					<div id="pwd" class="inforow">
						<label class="index">CMND:</label>

						<div class="infotext">
							<%
								String sCMND = "";
									for (Baomat baomat : listBaomat) {
										if (baomat.getCmnd() != null) {
											sCMND = baomat.getCmnd();
										} else {
											sCMND = "(chưa có thông tin)";
										}
							%>
							<label class="text"><%=sCMND%></label>
							<%
								}
							%>
						</div>
					</div>

					<div id="pwd" class="inforow">
						<label style="margin-left: 80px;" class="index">Ngày cấp:</label>

						<div class="infotext">
							<%
								Date sNgaycap = null;
									for (Baomat baomat : listBaomat) {
										if (baomat.getNgaycap() != null) {
											sNgaycap = baomat.getNgaycap();
										} else {
											sNgaycap = Date.valueOf("0001-01-01");
										}
							%>
							<label class="text"><%=sNgaycap%></label>
							<%
								}
							%>
						</div>
					</div>

					<div id="pwd" class="inforow">
						<label style="margin-left: 80px;" class="index">Nơi cấp:</label>

						<div class="infotext">
							<%
								String sNoicap = "";
									for (Baomat baomat : listBaomat) {
										if (baomat.getNoicap() != null) {
											sNoicap = baomat.getNoicap();
										} else {
											sNoicap = "(chưa có thông tin)";
										}
							%>
							<label class="text"><%=sNoicap%></label>
							<%
								}
							%>
						</div>
					</div>

					<label style="margin-left: 170px; color: red;"><%=err_changeprotect%></label>
					<label style="margin-left: 180px; color: green;"><%=finish_changeprotect%></label>


					<!--Update thông tin-->
					<div id="update_info" style="display: none;">
						<span style="color: #008080; font-size: 14px;">___(Bạn hãy
							nhập thông tin để cập nhật! Chú ý không bỏ trống các trường có
							dấu <span class="required">*</span> )___
						</span> <label class="index_formtdmk">Email bảo vệ:</label>
						<div class="matkhaucu">
							<input class="txtmatkhaucu" type="text" name="emailbaove"></input>
							<span class="required">*</span>
						</div>

						<label class="index_formtdmk">Số CMND:</label>
						<div class="matkhaucu">
							<input class="txtmatkhaucu" type="text" name="cmnd"></input> <span
								class="required">*</span>
						</div>

						<label style="margin-left: 50px;" class="index_formtdmk">Ngày
							cấp:</label>
						<div class="matkhaucu">
							<input class="txtmatkhaucu" type="date" name="ngaycap"></input> <span
								class="required">*</span>

						</div>

						<label class="index_formtdmk">Nơi cấp:</label>
						<div class="matkhaucu">
							<input class="txtmatkhaucu" type="text" name="noicap"></input> <span
								class="required">*</span>

						</div>

						<div id="submit">
							<input class="cnbq" type="submit" name="command" value="Cập nhật"></input>

						</div>


					</div>
					<!--End Update thông tin-->

				</div>

			</div>
		</form>
		<!--End Right-->
	</div>

</div>




<jsp:include page="includes/footer.jsp"></jsp:include>
<%
	}
%>